package sort

type BubbleSort struct {
	BaseSort
}

func (self BubbleSort) Sort() {
	length := self.Len()
	for i := 0; i < length; i++ {
		for j := 1; j < length; j++ {
			if self.Less(j, j-1) {
				self.Swap(j-1, j)
			}
		}
	}
}

func (self BubbleSort) Name() string {
	return "冒泡排序"
}
